import Vue from "vue";
import VueI18n from "vue-i18n";
import Cookie from "js-cookie"; // 引入cookie包

import elementEN from "element-ui/lib/locale/lang/en"; // 引入饿了么的英文包
import elementZH from "element-ui/lib/locale/lang/zh-CN"; // 引入饿了么的中文包
import elementJA from "element-ui/lib/locale/lang/ja";

import customZH from "./zh"; // 引入自定义中文包
import customEN from "./en"; // 引入自定义英文包

Vue.use(VueI18n);

const messages = {
  en: {
    ...elementEN,
    ...customEN
  },
  zh: {
    ...elementZH,
    ...customZH
  },
  ja: {
    ...elementJA
  }
};

export default new VueI18n({
  //locale: "ja", // 语言标识
  locale: Cookie.get("language") || "zh", // 从cookie中获取语言类型 获取不到就是中文
  messages
});
